Skip to content

feat(setup): inject Windows-node guidance into AGENTS.md after pairing - #659

Merged
steipete merged 8 commits into
openclaw:mainfrom
paulcam206:master
Jul 6, 2026
Merged

feat(setup): inject Windows-node guidance into AGENTS.md after pairing#659
steipete merged 8 commits into
openclaw:mainfrom
paulcam206:master

Conversation

@paulcam206

@paulcam206 paulcam206 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a setup-owned Windows-node context block to the effective main/default agent workspace after onboarding. This teaches the gateway agent to route Windows work through the paired tray node instead of attempting Windows-only operations inside WSL.

The maintainer pass integrates the feature into the native onboarding wizard and hardens it for upgrades, retries, custom agent workspaces, and deterministic uninstall.

Behavior

  • Runs Windows context finalization after onboarding, including the wizard-only path.
  • Resolves the effective main/default agent workspace from openclaw agents list --json; per-agent overrides do not rewrite global defaults.
  • Feature-detects openclaw setup --baseline while retaining compatibility with the pinned 2026.6.11 gateway CLI.
  • Injects one managed block into AGENTS.md, preserving unrelated content, CRLF, and existing file mode.
  • Uses WSL stdin execution so wsl.exe cannot mutate shell variables in the script argument.
  • Retries only the Windows integration step after onboarding succeeds; no repeated provider/device setup.
  • Records the exact distro, user, and workspace target so uninstall removes the block from the location that was actually modified.
  • Retains cleanup state on failure and rejects unsafe symlink mutation.

Implementation notes

The file mutation remains POSIX-shell based and does not assume Node.js exists in a fresh WSL distro. Managed markers make repeated application idempotent and rollback scoped. A focused WSL argv reference documents why scripts containing shell variables must be sent through stdin.

Validation

  • AutoReview full-branch review: clean; no accepted/actionable findings.
  • Windows 11 ARM64 VM: OpenClaw.SetupEngine.Tests 418/418 passed.
  • Windows 11 ARM64 VM, fresh Git clone: Shared 2697 passed / 31 skipped; Tray 1578/1578 passed; full ARM64 build passed.
  • Windows 11 ARM64 VM: local dev installer built, installed side-by-side, launched the native wizard, and reached automatic WSL gateway creation.
  • The Apple-silicon Parallels VM cannot provide nested virtualization; the wizard surfaced HCS_E_HYPERV_NOT_INSTALLED with actionable recovery text at the expected boundary.
  • Exact-head CI: unit/integration suite, real WSL setup/connect, recovery shards, and x64/ARM64 builds all passed.

Co-authored with and based on the original contribution from @paulcam206.

@clawsweeper

clawsweeper Bot commented Jun 3, 2026

Copy link
Copy Markdown

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open: the refreshed branch removed the permissive tools.exec recommendations, but it still leaves workspace-global Windows-node routing guidance and can still block setup completion when optional AGENTS enrichment fails.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a user bug report, but the PR blockers are source-reproducible: the managed payload is broad at WindowsNodeContextSection.cs:9, and enrichment failure returns before setup completion in the current head.

Is this the best way to solve the issue?

No. The safer solution is scoped, explicit Windows-node guidance plus best-effort setup enrichment, with current-head proof of the revised setup behavior.

Security review:

Security review needs attention: The permissive exec-default advice was removed, but workspace-global routing guidance still has a concrete security-boundary concern for remote or multi-node sessions.

  • [medium] Workspace-global guidance can steer local node use — src/OpenClaw.SetupEngine/WindowsNodeContextSection.cs:9
    The managed AGENTS payload tells all sessions in the gateway workspace to route broad Windows tasks to the paired Windows node, which can cross the intended local-node boundary for remote-origin or future multi-node work.
    Confidence: 0.86

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-06-03T06:15:15Z, is older than 30 days, and the latest review rated it F.
  • proof blocker: real behavior proof is insufficient and proof tier is D, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • steipete: Peter Steinberger authored current-main commit adcb4c3 adding the Windows gateway onboarding wizard and also appears in the PR history hardening this feature branch. (role: recent onboarding contributor and PR hardening owner; confidence: high; commits: adcb4c378f90, 3b9915ced000, 4811763f8e15; files: src/OpenClaw.SetupEngine.UI/Pages/WizardPage.xaml.cs, src/OpenClaw.SetupEngine.UI/SetupWindow.xaml.cs, src/OpenClaw.SetupEngine/SetupSteps.cs)
  • shanselman: Scott Hanselman is the current-main blame source for much of the setup pipeline and wizard flow and left the focused scope/security review comments on this PR. (role: recent setup contributor and area reviewer; confidence: high; commits: 4166e0fd63f8; files: src/OpenClaw.SetupEngine/SetupPipeline.cs, src/OpenClaw.SetupEngine.UI/Pages/WizardPage.xaml.cs, src/OpenClaw.Tray.WinUI/App.xaml.cs)
  • ranjeshj: Ranjesh authored and closed the related gateway exec-policy issue with the explicit security-boundary direction that this PR must preserve. (role: related gateway exec-policy owner; confidence: medium; files: src/OpenClaw.SetupEngine/SetupSteps.cs, docs/ONBOARDING_WIZARD.md)

Codex review notes: model internal, reasoning high; reviewed against c9b5476a873f.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Jun 3, 2026
@paulcam206

Copy link
Copy Markdown
Contributor Author

just as a heads up -- this change is a little wonky in terms of what we're doing... it works, but I wouldn't say that it's elegant.

anyways, here's a completely clean install being asked to pop a notification:
image

@shanselman

Copy link
Copy Markdown
Collaborator

@paulcam206 does it only do it if the message is coming in via the Windows app?

@shanselman

Copy link
Copy Markdown
Collaborator

Automated Copilot review note from the wide PR triage pass:

I would not treat this as safe to merge at 90% confidence yet, even aside from the current conflict state. The core concern is scope: this PR injects Windows-node guidance into the gateway workspace's global AGENTS.md, so it can affect agent behavior for requests that did not originate from the local Windows tray chat — for example Telegram-originated work, remote/gateway sessions, or future multi-node scenarios.

Two things I think should be tightened before merge:

  1. Scope the guidance to cases where the task explicitly needs this paired Windows machine. The current wording can over-bias the agent toward the local Windows node for broadly described Windows/files/browser/notification work, even when the request came from another channel or another node context.
  2. Avoid putting permission-relaxing config advice in global agent guidance. The suggested openclaw config set tools.exec.ask off and openclaw config set tools.exec.security full commands are especially risky when Telegram/remote messages may influence the agent. If those defaults are needed for setup, they should be handled by explicit setup/config UX with user consent, not broad AGENTS.md instructions.

Separately, because this is post-pairing enrichment, I would prefer injection failures/timeouts/malformed existing markers to be non-terminal or self-healing where possible. Optional guidance should not block onboarding after pairing succeeds.

@shanselman

Copy link
Copy Markdown
Collaborator

Thanks for the proof and the implementation here. I don't think this is safe to merge as-is yet because the generated AGENTS.md guidance is workspace-global, so it can influence sessions regardless of where the request originated — local tray, remote gateway, Telegram, or another paired node. It also currently suggests broad tools.exec permission changes, which is risky guidance to inject automatically.

Could you please revise this so the injected guidance is clearly scoped to tasks that intentionally need this paired Windows node, remove or soften the permissive tools.exec config recommendations, and ensure AGENTS enrichment is non-blocking for pairing/onboarding if it times out or fails? After that, this should get another focused review.

@ranjeshj
ranjeshj marked this pull request as draft June 18, 2026 05:10
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 18, 2026
paulcam206 and others added 7 commits July 6, 2026 07:24
Add WindowsNodeBootstrapContextStep that runs after node pairing and
injects a managed BEGIN/END block into the gateway's AGENTS.md
(workspace resolved from `openclaw config get agents.defaults.workspace`,
or from a `WindowsNodeContext.WorkspacePath` override). The injected
block tells the running OpenClaw agent how to use the paired Windows
tray node (nodes tool, exec host=node, tools.exec defaults, etc.).

The file mutation is pure POSIX shell + awk + base64 — no Node.js
dependency, no embedded JS, no heredocs. Bare WSL distros (and the
gateway distro) do not have node installed, so the previous
node-based approach failed at runtime.

Scripts that need bash variable handling are piped to `bash -s` via
stdin instead of being passed as argv to `bash -c`, because wsl.exe
performs shell variable expansion on argv before bash sees it and
silently drops user-defined $var references. New
docs/WSL_EXE_ARGV_PITFALL.md documents the footgun, the empirical
reproduction against fresh Ubuntu-26.04, and the ranked fixes.

Notable changes:
* CommandRunner.RunInWslAsync gains opt-in `inputViaStdin: true`
  that switches argv to `bash -s` and pipes the script over stdin
* WindowsNodeBootstrapContextStep computes the absolute workspace
  path once via ExpandLinuxPath and threads it through both
  `openclaw setup --workspace` and the apply script, so `~/foo` or
  relative-path overrides cannot land in different directories
* RunOpenclawSetupAsync and ResolveWorkspacePathAsync use the stdin
  path because their scripts include $PATH via WslPathPrefix
* Apply script is idempotent and handles missing/symlink/malformed
  AGENTS.md; rollback removes the managed block in-place
* Cross-references in AGENTS.md and docs/WINDOWS_NODE_TESTING.md
  surface the pitfall doc from likely discovery points
* Tests cover apply/rollback shape, override expansion, per-call
  stdin-vs-argv invariants, and a tilde-override regression
* Verified end-to-end against bare Ubuntu-26.04 (no openclaw, no
  node): apply-to-missing, apply-preserves-content, idempotency
  (exactly 1 BEGIN marker after second apply), rollback restores
  original content

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@steipete
steipete marked this pull request as ready for review July 6, 2026 08:39
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Jul 6, 2026
@clawsweeper clawsweeper Bot removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69b85fbfa8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3074 to +3075
if (result.TimedOut || result.ExitCode != 0)
return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fall back to default workspace when agents list is absent

In the explicit skip-onboard path (SkipWizardAsync or RunGatewayWizardStep.CanSkip), no agent workspace may have been initialized yet because the baseline initializer runs later in this step. Returning null as soon as openclaw agents list --json exits non-zero makes Windows-node context finalization fail before consulting agents.defaults.workspace or running openclaw setup --workspace, so a fresh local setup where the user chooses to skip OpenClaw onboard can get stuck instead of completing with the default workspace. Please fall back to the configured/default workspace when the agents list is unavailable.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 6, 2026
@steipete
steipete merged commit 698efcc into openclaw:main Jul 6, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants